import { GSprite } from "../../../../com/mui/controls/GSprite";
import { PageTool } from "../../../common/global/PageTool";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { SRobIslandMiniPlayer } from "../../../../Message/Game/SRobIslandMiniPlayer";
import { PetIslandFightMemberListItemRenderer } from "./renderer/PetIslandFightMemberListItemRenderer";
import { DisplayUtil } from "../../../common/DisplayUtil";
import { ObjCreate } from "../common/ObjCreate";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { ScrollPolicy } from "../../../../fl/controls/ScrollPolicy";
import { PageSelecter } from "../common/pageSelect/PageSelecter";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
import { GButton } from "../../../../com/mui/controls/GButton";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
import { GTileList } from "../../../../com/mui/controls/GTileList";
//class PetIslandFightMemberListPanel
    
    export  class PetIslandFightMemberListPanel extends GSprite
    {
        constructor(arg1: string)
        {
            super();
            this._pageTool = new PageTool([], 9);
            this._title = arg1;
            this.init();
            return;
        }

        /* internal  */onEquipmentPageChange(arg1: Object /* flash.events.Event */=null): void
        {
            var loc1=this._pageSelecter.currentPage;
            this._list.dataProvider = new DataProvider(this._pageTool.getByPageNo(loc1));
            this._list.drawNow();
            return;
        }

        /* internal  */clickCloseHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc2=null;
            var loc3=null;
            var loc1=this._list.dataProvider.length;
            var loc4=0;
            while (loc4 < loc1) 
            {
                loc2 = this._list.getItemAt(loc4) as SRobIslandMiniPlayer;
                if (loc3 = this._list.itemToCellRenderer(loc2) as PetIslandFightMemberListItemRenderer) 
                {
                    loc3.dispose();
                }
                ++loc4;
            }
            DisplayUtil.removeMe(this);
            return;
        }

        public set data(arg1: Array<any>)
        {
            this._pageTool.array = arg1;
            this._pageSelecter.currentPage = this._pageTool.currentPage;
            this._pageSelecter.maxPage = this._pageTool.pagesCount;
            this._list.dataProvider = new DataProvider(this._pageTool.getByPageNo(this._pageSelecter.currentPage));
            this._list.drawNow();
            return;
        }

        /* internal  */init(): void
        {
            ObjCreate.createBg(0, 0, 180, 300, this);
            this._closeBtn = ObjCreate.createGButton("", 153, 3, 27, 28, this, "RedBigXCloseBtn");
            this._closeBtn.addEventListener(flash.events.MouseEvent.CLICK, this.clickCloseHandler);
            this._titleTxt = ObjCreate.createGTextField(this._title, 43, 5, 100, 20, this, new GTextFormat(FontUtil.songtiName, 14, 15788607));
            this._list = ObjCreate.createTileList(0, 30, 180, 230, this);
            this._list.scrollPolicy = ScrollPolicy.OFF;
            this._list.columnWidth = 180;
            this._list.rowHeight = 30;
            this._list.setStyle("cellRenderer", PetIslandFightMemberListItemRenderer);
            this._pageSelecter = ObjCreate.createPageSelecter(29, 276, this);
            this._pageSelecter.mode = PageSelecter.CompleteMode;
            this._pageSelecter.addEventListener(flash.events.Event.CHANGE, this.onEquipmentPageChange);
            return;
        }

        /* internal */ /* var */_title: string;

        /* internal */ /* var */_bg: ScaleBitmap;

        /* internal */ /* var */_closeBtn: GButton;

        /* internal */ /* var */_titleTxt: GTextFiled;

        /* internal */ /* var */_list: GTileList;

        /* internal */ /* var */_pageSelecter: PageSelecter;

        /* internal */ /* var */_pageTool: PageTool;
    }
